package com.ailink.spring;

import com.ailink.spring.aop.MyAop;
import com.ailink.spring.event.MyApplicationEvent;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class SpringTest {
    public static void main(String[] args) {
        // AnnotationConfigServletWebServerApplicationContext  ServletWebServerApplicationContext
        // AnnotationConfigApplicationContext
        // GenericApplicationContext
        // AbstractApplicationContext
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);

        context.publishEvent(new MyApplicationEvent(new Object()));

        MyComponent component = context.getBean(MyComponent.class);

        context.getBean(MultiComponent.class);
        context.getBean(MultiComponent.class);
        System.out.println(component);

        MyPropertySources myPropertySources = context.getBean(MyPropertySources.class);
        System.out.println(myPropertySources);

        MyLookup myLookup = context.getBean(MyLookup.class);
        Ab lookupAb = myLookup.lookup();
        System.out.println(lookupAb);

        MyAop myAop = context.getBean(MyAop.class);
        String something = myAop.say("my aop");
        System.out.println(something);

        context.close();
    }
}
